

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  <meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>cephfs-shell -- 与 CephFS 对话的类 shell 工具 &mdash; Ceph Documentation</title>
  

  
  <link rel="stylesheet" href="../../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/graphviz.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/css/custom.css" type="text/css" />

  
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
        <script src="../../../_static/jquery.js"></script>
        <script src="../../../_static/_sphinx_javascript_frameworks_compat.js"></script>
        <script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
        <script src="../../../_static/doctools.js"></script>
        <script src="../../../_static/sphinx_highlight.js"></script>
    
    <script type="text/javascript" src="../../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../../genindex/" />
    <link rel="search" title="Search" href="../../../search/" />
    <link rel="next" title="内核驱动支持的功能" href="../../../cephfs/kernel-features/" />
    <link rel="prev" title="在 Windows 上挂载 CephFS" href="../../../cephfs/ceph-dokan/" /> 
</head>

<body class="wy-body-for-nav">

   
  <header class="top-bar">
    <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../../../" class="icon icon-home" aria-label="Home"></a></li>
          <li class="breadcrumb-item"><a href="../../../cephfs/">Ceph 文件系统</a></li>
      <li class="breadcrumb-item active">cephfs-shell -- 与 CephFS 对话的类 shell 工具</li>
      <li class="wy-breadcrumbs-aside">
            <a href="../../../_sources/man/8/cephfs-shell.rst.txt" rel="nofollow"> View page source</a>
      </li>
  </ul>
  <hr/>
</div>
  </header>
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #eee" >
          

          
            <a href="../../../" class="icon icon-home"> Ceph
          

          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../../search/" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../../start/">Ceph 简介</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../install/">安装 Ceph</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../cephadm/">Cephadm</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../rados/">Ceph 存储集群</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../../../cephfs/">Ceph 文件系统</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../../../cephfs/#cephfs">CephFS 入门</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../cephfs/#id4">管理</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../../../cephfs/#id5">挂载 CephFS</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="../../../cephfs/client-config-ref/"> 客户端配置选项</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../cephfs/client-auth/"> 客户端认证</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../cephfs/mount-prerequisites/"> 挂载 CephFS: 前提条件</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../cephfs/mount-using-kernel-driver/"> 用内核驱动挂载 CephFS 文件系统</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../cephfs/mount-using-fuse/"> 用 FUSE 挂载 CephFS</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../cephfs/ceph-dokan/"> 在 Windows 上挂载 CephFS</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#"> CephFS Shell 的用法</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id1">提纲</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id2">描述</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id3">选项</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id4">命令</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id5">CephFS Shell 配置文件</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id6">退出代码</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id7">相关文件</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../../cephfs/kernel-features/"> 内核驱动支持的功能</a></li>
<li class="toctree-l3"><a class="reference internal" href="../ceph-fuse/"> ceph-fuse 手册页</a></li>
<li class="toctree-l3"><a class="reference internal" href="../mount.ceph/"> mount.ceph 手册页</a></li>
<li class="toctree-l3"><a class="reference internal" href="../mount.fuse.ceph/"> mount.fuse.ceph 手册页</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../../cephfs/#id6">CephFS 内幕</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../cephfs/#id7">故障排除和灾难恢复</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../cephfs/#id9">更多细节</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../../rbd/">Ceph 块设备</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../radosgw/">Ceph 对象网关</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../mgr/">Ceph 管理器守护进程</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../mgr/dashboard/">Ceph 仪表盘</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../monitoring/">监控概览</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../api/">API 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../architecture/">体系结构</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../dev/developer_guide/">开发者指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../dev/internals/">Ceph 内幕</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../governance/">项目管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../foundation/">Ceph 基金会</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../ceph-volume/">ceph-volume</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../releases/general/">Ceph 版本（总目录）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../releases/">Ceph 版本（索引）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../security/">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../hardware-monitoring/">硬件监控</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../glossary/">Ceph 术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../jaegertracing/">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../translation_cn/">中文版翻译资源</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../../">Ceph</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
<div id="dev-warning" class="admonition note">
  <p class="first admonition-title">Notice</p>
  <p class="last">This document is for a development version of Ceph.</p>
</div>
  <div id="docubetter" align="right" style="padding: 5px; font-weight: bold;">
    <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
  </div>

  
  <section id="cephfs-shell-cephfs-shell">
<span id="cephfs-shell"></span><h1>cephfs-shell -- 与 CephFS 对话的类 shell 工具<a class="headerlink" href="#cephfs-shell-cephfs-shell" title="Permalink to this heading"></a></h1>
<section id="id1">
<h2>提纲<a class="headerlink" href="#id1" title="Permalink to this heading"></a></h2>
<div class="line-block">
<div class="line"><strong>cephfs-shell</strong> [options] [command]</div>
<div class="line"><strong>cephfs-shell</strong> [options] -- [command, command,…]</div>
</div>
</section>
<section id="id2">
<h2>描述<a class="headerlink" href="#id2" title="Permalink to this heading"></a></h2>
<p>CephFS Shell 提供了类似 shell 的命令，可以直接与 Ceph 文件系统交互。</p>
<p>此工具可以在交互模式下使用，也可以在非交互模式下使用。
在前一种模式下， cephfs-shell 会打开一个 shell 会话，
在指定命令完成后，它会打印出提示字符串，并无限期等待。
shell 会话完成后， cephfs-shell 会退出，
其状态码就是执行的最后一个完成命令的返回值。
在非交互式模式下， cephfs-shell 会发出一个命令，
并且在那个命令执行完毕后带着它的返回值退出。</p>
<p>CephFS Shell 的行为可以用 <code class="docutils literal notranslate"><span class="pre">cephfs-shell.conf</span></code> 调整。
详情见 <a class="reference internal" href="#id5">CephFS Shell 配置文件</a> 。</p>
</section>
<section id="id3">
<h2>选项<a class="headerlink" href="#id3" title="Permalink to this heading"></a></h2>
<dl class="std option">
<dt class="sig sig-object std" id="cmdoption-cephfs-shell-b">
<span id="cmdoption-cephfs-shell-batch"></span><span class="sig-name descname"><span class="pre">-b</span></span><span class="sig-prename descclassname"></span><span class="sig-prename descclassname"><span class="pre">,</span> </span><span class="sig-name descname"><span class="pre">--batch</span></span><span class="sig-prename descclassname"> <span class="pre">FILE</span></span><a class="headerlink" href="#cmdoption-cephfs-shell-b" title="Permalink to this definition"></a></dt>
<dd><p>批处理文件的路径。</p>
</dd></dl>

<dl class="std option">
<dt class="sig sig-object std" id="cmdoption-cephfs-shell-c">
<span id="cmdoption-cephfs-shell-config"></span><span class="sig-name descname"><span class="pre">-c</span></span><span class="sig-prename descclassname"></span><span class="sig-prename descclassname"><span class="pre">,</span> </span><span class="sig-name descname"><span class="pre">--config</span></span><span class="sig-prename descclassname"> <span class="pre">FILE</span></span><a class="headerlink" href="#cmdoption-cephfs-shell-c" title="Permalink to this definition"></a></dt>
<dd><p>cephfs-shell.conf 的路径。</p>
</dd></dl>

<dl class="std option">
<dt class="sig sig-object std" id="cmdoption-cephfs-shell-f">
<span id="cmdoption-cephfs-shell-fs"></span><span class="sig-name descname"><span class="pre">-f</span></span><span class="sig-prename descclassname"></span><span class="sig-prename descclassname"><span class="pre">,</span> </span><span class="sig-name descname"><span class="pre">--fs</span></span><span class="sig-prename descclassname"> <span class="pre">FS</span></span><a class="headerlink" href="#cmdoption-cephfs-shell-f" title="Permalink to this definition"></a></dt>
<dd><p>要挂载的文件系统的名字。</p>
</dd></dl>

<dl class="std option">
<dt class="sig sig-object std" id="cmdoption-cephfs-shell-t">
<span id="cmdoption-cephfs-shell-test"></span><span class="sig-name descname"><span class="pre">-t</span></span><span class="sig-prename descclassname"></span><span class="sig-prename descclassname"><span class="pre">,</span> </span><span class="sig-name descname"><span class="pre">--test</span></span><span class="sig-prename descclassname"> <span class="pre">FILE</span></span><a class="headerlink" href="#cmdoption-cephfs-shell-t" title="Permalink to this definition"></a></dt>
<dd><p>FILE 文件里是供测试的路径名录。</p>
</dd></dl>

<div class="admonition note">
<p class="admonition-title">Note</p>
<p>cephfs-shell 依赖最新版的 cmd2 模块。
如果 CephFS 是从源码安装的，在构建目录下执行 cephfs-shell 即可。
也可以用 virtualenv 这样执行：</p>
</div>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="o">[</span>build<span class="o">]</span>$<span class="w"> </span>python3<span class="w"> </span>-m<span class="w"> </span>venv<span class="w"> </span>venv<span class="w"> </span><span class="o">&amp;&amp;</span><span class="w"> </span><span class="nb">source</span><span class="w"> </span>venv/bin/activate<span class="w"> </span><span class="o">&amp;&amp;</span><span class="w"> </span>pip3<span class="w"> </span>install<span class="w"> </span>cmd2<span class="w"> </span>colorama
<span class="o">[</span>build<span class="o">]</span>$<span class="w"> </span><span class="nb">source</span><span class="w"> </span>vstart_environment.sh<span class="w"> </span><span class="o">&amp;&amp;</span><span class="w"> </span><span class="nb">source</span><span class="w"> </span>venv/bin/activate<span class="w"> </span><span class="o">&amp;&amp;</span><span class="w"> </span>python3<span class="w"> </span>../src/tools/cephfs/shell/cephfs-shell
</pre></div>
</div>
</section>
<section id="id4">
<h2>命令<a class="headerlink" href="#id4" title="Permalink to this heading"></a></h2>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>除了 Ceph 文件系统， CephFS Shell 命令行还能直接与本地文件系统交互。
要这样做，必须在 CephFS Shell 命令前面加上 <code class="docutils literal notranslate"><span class="pre">!</span></code> （感叹号）。</p>
<p>用法：</p>
<blockquote>
<div><p>!&lt;cephfs_shell_command&gt;</p>
</div></blockquote>
<p>例如，</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>CephFS:~/&gt;&gt;&gt;<span class="w"> </span>!ls<span class="w"> </span><span class="c1"># Lists the local file system directory contents.</span>
CephFS:~/&gt;&gt;&gt;<span class="w"> </span>ls<span class="w">  </span><span class="c1"># Lists the Ceph File System directory contents.</span>
</pre></div>
</div>
</div>
<section id="mkdir">
<h3>mkdir<a class="headerlink" href="#mkdir" title="Permalink to this heading"></a></h3>
<p>如果指定目录不存在，就创建它们。</p>
<p>用法：</p>
<blockquote>
<div><p>mkdir [-option] &lt;directory&gt;…</p>
</div></blockquote>
<ul class="simple">
<li><p>directory - 将要创建的目录名</p></li>
</ul>
<dl>
<dt>选项：</dt><dd><dl class="option-list">
<dt><kbd><span class="option">-m <var>MODE</var></span></kbd></dt>
<dd><p>设置新目录的访问模式。</p>
</dd>
<dt><kbd><span class="option">-p</span>, <span class="option">--parent</span></kbd></dt>
<dd><p>如有必要，创建其父目录。加上此选项后，目录已存在也不会报错。</p>
</dd>
</dl>
</dd>
</dl>
</section>
<section id="put">
<h3>put<a class="headerlink" href="#put" title="Permalink to this heading"></a></h3>
<p>把本地文件系统上的一个文件、目录复制到 Ceph 文件系统。</p>
<p>用法：</p>
<blockquote>
<div><p>put [options] &lt;source_path&gt; &lt;target_path&gt;</p>
</div></blockquote>
<ul class="simple">
<li><dl class="simple">
<dt>source_path - 要复制到 cephfs 的本地文件、目录的路径</dt><dd><ul>
<li><p>如果是 <cite>.</cite> 就复制当前工作目录内的所有文件、目录。</p></li>
<li><p>如果是 <cite>-</cite> 就从标准输入读取。</p></li>
</ul>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>target_path - 远程目录路径，文件、目录将复制到这里。</dt><dd><ul>
<li><p>如果是 <cite>.</cite> ，文件、目录将复制到远程的工作目录内。</p></li>
</ul>
</dd>
</dl>
</li>
</ul>
<dl>
<dt>选项：</dt><dd><dl class="option-list">
<dt><kbd><span class="option">-f</span>, <span class="option">--force</span></kbd></dt>
<dd><p>如果目的地已存在此文件就覆盖掉它。</p>
</dd>
</dl>
</dd>
</dl>
</section>
<section id="get">
<h3>get<a class="headerlink" href="#get" title="Permalink to this heading"></a></h3>
<p>把 Ceph 文件系统上的一个文件复制到本地文件系统。</p>
<p>用法：</p>
<blockquote>
<div><p>get [options] &lt;source_path&gt; &lt;target_path&gt;</p>
</div></blockquote>
<ul class="simple">
<li><dl class="simple">
<dt>source_path - 将被复制到本地文件系统的远程文件、目录路径</dt><dd><ul>
<li><p>如果是 <cite>.</cite> ，就复制远程工作目录下的所有文件、目录。</p></li>
</ul>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>target_path - 本地目录路径，文件、目录将复制到这里。</dt><dd><ul>
<li><p>如果是 <cite>.</cite> ，文件、目录就会复制到本地工作目录。</p></li>
<li><p>如果是 <cite>-</cite> ，把输出写到标准输出。</p></li>
</ul>
</dd>
</dl>
</li>
</ul>
<dl>
<dt>选项：</dt><dd><dl class="option-list">
<dt><kbd><span class="option">-f</span>, <span class="option">--force</span></kbd></dt>
<dd><p>如果目的地已存在此文件就覆盖掉它。</p>
</dd>
</dl>
</dd>
</dl>
</section>
<section id="ls">
<h3>ls<a class="headerlink" href="#ls" title="Permalink to this heading"></a></h3>
<p>罗列出当前工作目录内的所有文件和目录。</p>
<p>用法：</p>
<blockquote>
<div><p>ls [option] [directory]…</p>
</div></blockquote>
<ul class="simple">
<li><dl class="simple">
<dt>directory - 目录名，会罗列出它里面的文件、目录</dt><dd><ul>
<li><p>默认会罗列出当前工作目录内的文件、目录。</p></li>
</ul>
</dd>
</dl>
</li>
</ul>
<dl>
<dt>选项：</dt><dd><dl class="option-list">
<dt><kbd><span class="option">-l</span>, <span class="option">--long</span></kbd></dt>
<dd><p>以长格式罗列 - 显示权限</p>
</dd>
<dt><kbd><span class="option">-r</span>, <span class="option">--reverse</span></kbd></dt>
<dd><p>反向排序</p>
</dd>
<dt><kbd><span class="option">-H</span></kbd></dt>
<dd><p>人类可读</p>
</dd>
<dt><kbd><span class="option">-a</span>, <span class="option">-a<var>ll</var></span></kbd></dt>
<dd><p>忽略以 . 打头的条目</p>
</dd>
<dt><kbd><span class="option">-S</span></kbd></dt>
<dd><p>按文件尺寸排序</p>
</dd>
</dl>
</dd>
</dl>
</section>
<section id="cat">
<h3>cat<a class="headerlink" href="#cat" title="Permalink to this heading"></a></h3>
<p>连结文件内容并打印在标准输出上。</p>
<p>用法：</p>
<blockquote>
<div><p>cat  &lt;file&gt;….</p>
</div></blockquote>
<ul class="simple">
<li><p>file - 文件名</p></li>
</ul>
</section>
<section id="ln">
<h3>ln<a class="headerlink" href="#ln" title="Permalink to this heading"></a></h3>
<p>给现有文件增加一个硬链接，或者给现有文件或目录创建一个符号链接。</p>
<p>用法：</p>
<blockquote>
<div><p>ln [options] &lt;target&gt; [link_name]</p>
</div></blockquote>
<ul class="simple">
<li><p>target - 准备创建一个链接的源文件/目录</p></li>
<li><p>link_name - 用指定的名字 link_name 链接到目标</p></li>
</ul>
<dl>
<dt>选项：</dt><dd><dl class="option-list">
<dt><kbd><span class="option">-s</span>, <span class="option">--symbolic</span></kbd></dt>
<dd><p>创建符号链接</p>
</dd>
<dt><kbd><span class="option">-v</span>, <span class="option">--verbose</span></kbd></dt>
<dd><p>打印各个被链接文件的名字</p>
</dd>
<dt><kbd><span class="option">-f</span>, <span class="option">--force</span></kbd></dt>
<dd><p>强行创建链接、符号链接</p>
</dd>
</dl>
</dd>
</dl>
</section>
<section id="cd">
<h3>cd<a class="headerlink" href="#cd" title="Permalink to this heading"></a></h3>
<p>改变当前工作目录。</p>
<p>用法：</p>
<blockquote>
<div><p>cd [directory]</p>
</div></blockquote>
<ul class="simple">
<li><dl class="simple">
<dt>directory - 路径、目录名。如果没指定目录，它就改变到根目录。</dt><dd><ul>
<li><p>如果是 ‘..’ ，就移动到当前目录的父目录。</p></li>
</ul>
</dd>
</dl>
</li>
</ul>
</section>
<section id="cwd">
<h3>cwd<a class="headerlink" href="#cwd" title="Permalink to this heading"></a></h3>
<p>获取当前工作目录。</p>
<p>用法：</p>
<blockquote>
<div><p>cwd</p>
</div></blockquote>
</section>
<section id="quit-ctrl-d">
<h3>quit/Ctrl-D<a class="headerlink" href="#quit-ctrl-d" title="Permalink to this heading"></a></h3>
<p>关闭当前 shell 。</p>
</section>
<section id="chmod">
<h3>chmod<a class="headerlink" href="#chmod" title="Permalink to this heading"></a></h3>
<p>更改文件、目录的权限。</p>
<p>用法：</p>
<blockquote>
<div><p>chmod &lt;mode&gt; &lt;file/directory&gt;</p>
</div></blockquote>
</section>
<section id="mv">
<h3>mv<a class="headerlink" href="#mv" title="Permalink to this heading"></a></h3>
<p>把文件、目录从源头移动到目的地。</p>
<p>用法：</p>
<blockquote>
<div><p>mv &lt;source_path&gt; &lt;destination_path&gt;</p>
</div></blockquote>
</section>
<section id="rmdir">
<h3>rmdir<a class="headerlink" href="#rmdir" title="Permalink to this heading"></a></h3>
<p>删除一或多个目录。</p>
<p>用法：</p>
<blockquote>
<div><p>rmdir &lt;directory_name&gt;…..</p>
</div></blockquote>
</section>
<section id="rm">
<h3>rm<a class="headerlink" href="#rm" title="Permalink to this heading"></a></h3>
<p>删除一或多个文件。</p>
<p>用法：</p>
<blockquote>
<div><p>rm &lt;file_name/pattern&gt;…</p>
</div></blockquote>
</section>
<section id="write">
<h3>write<a class="headerlink" href="#write" title="Permalink to this heading"></a></h3>
<p>创建并写入一个文件。</p>
<p>用法：</p>
<blockquote>
<div><p>write &lt;file_name&gt;
&lt;Enter Data&gt;
Ctrl+D Exit.</p>
</div></blockquote>
</section>
<section id="lls">
<h3>lls<a class="headerlink" href="#lls" title="Permalink to this heading"></a></h3>
<p>罗列指定目录里的所有文件和目录。如果没指定 path ，就会罗列出当前本地目录内的文件和目录。</p>
<p>用法：</p>
<blockquote>
<div><p>lls &lt;path&gt;…..</p>
</div></blockquote>
</section>
<section id="lcd">
<h3>lcd<a class="headerlink" href="#lcd" title="Permalink to this heading"></a></h3>
<p>进入指定的本地目录。</p>
<p>用法：</p>
<blockquote>
<div><p>lcd &lt;path&gt;</p>
</div></blockquote>
</section>
<section id="lpwd">
<h3>lpwd<a class="headerlink" href="#lpwd" title="Permalink to this heading"></a></h3>
<p>打印出当前本地目录的绝对路径。</p>
<p>用法：</p>
<blockquote>
<div><p>lpwd</p>
</div></blockquote>
</section>
<section id="umask">
<h3>umask<a class="headerlink" href="#umask" title="Permalink to this heading"></a></h3>
<p>设置和获取文件模式的创建掩码。</p>
<p>用法：</p>
<blockquote>
<div><p>umask [mode]</p>
</div></blockquote>
</section>
<section id="alias">
<h3>alias<a class="headerlink" href="#alias" title="Permalink to this heading"></a></h3>
<p>定义或显示别名。</p>
<p>用法：</p>
<blockquote>
<div><p>alias [name] | [&lt;name&gt; &lt;value&gt;]</p>
</div></blockquote>
<ul class="simple">
<li><p>name - 要查询、新增、或替换的别名的名字。</p></li>
<li><p>value - 别名解析到的内容（新增或删除时），可以包含空格、并且不需要加引号。</p></li>
</ul>
</section>
<section id="run-pyscript">
<h3>run_pyscript<a class="headerlink" href="#run-pyscript" title="Permalink to this heading"></a></h3>
<p>在控制台里运行一个 python 脚本。</p>
<p>用法：</p>
<blockquote>
<div><p>run_pyscript &lt;script_path&gt; [script_arguments]</p>
</div></blockquote>
<ul class="simple">
<li><p>在这个脚本里，可以用 cmd （你的自定义命令）执行控制台命令。
但是，在这个脚本里你不能运行嵌套的 py 或 pyscript 命令。
包含空格的路径或参数必须用引号括起来。</p></li>
</ul>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>cmd2 版本为 0.9.13 或更低时，此命令名为 <code class="docutils literal notranslate"><span class="pre">pyscript</span></code> 。</p>
</div>
</section>
<section id="py">
<h3>py<a class="headerlink" href="#py" title="Permalink to this heading"></a></h3>
<p>调用 python 命令、 shell 或脚本。</p>
<p>用法：</p>
<blockquote>
<div><p>py &lt;command&gt;: 执行一个 Python 命令。
py: 进入交互式 Python 模式。</p>
</div></blockquote>
</section>
<section id="shortcuts">
<h3>shortcuts<a class="headerlink" href="#shortcuts" title="Permalink to this heading"></a></h3>
<p>列出可用的快捷方式（别名）。</p>
<p>用法：</p>
<blockquote>
<div><p>shortcuts</p>
</div></blockquote>
</section>
<section id="history">
<h3>history<a class="headerlink" href="#history" title="Permalink to this heading"></a></h3>
<p>查看、运行、编辑、和保存之前输入的命令。</p>
<p>用法：</p>
<blockquote>
<div><p>history [-h] [-r | -e | -s | -o FILE | -t TRANSCRIPT] [arg]</p>
</div></blockquote>
<dl>
<dt>选项：</dt><dd><dl class="option-list">
<dt><kbd><span class="option">-h</span></kbd></dt>
<dd><p>显示此帮助信息而后退出</p>
</dd>
<dt><kbd><span class="option">-r</span></kbd></dt>
<dd><p>运行选定的（多条）历史条目</p>
</dd>
<dt><kbd><span class="option">-e</span></kbd></dt>
<dd><p>编辑而后运行选定的（多条）历史条目</p>
</dd>
<dt><kbd><span class="option">-s</span></kbd></dt>
<dd><p>脚本格式，没有分隔行</p>
</dd>
<dt><kbd><span class="option">-o <var>FILE</var></span></kbd></dt>
<dd><p>把命令输出到一个脚本文件</p>
</dd>
<dt><kbd><span class="option">-t <var>TRANSCRIPT</var></span></kbd></dt>
<dd><p>把命令及其结果输出到一个笔录文件</p>
</dd>
</dl>
</dd>
</dl>
</section>
<section id="unalias">
<h3>unalias<a class="headerlink" href="#unalias" title="Permalink to this heading"></a></h3>
<p>取消别名。</p>
<p>用法：</p>
<blockquote>
<div><p>unalias [-a] name [name …]</p>
</div></blockquote>
<ul class="simple">
<li><p>name - 要取消的别名名字</p></li>
</ul>
<dl>
<dt>选项：</dt><dd><dl class="option-list">
<dt><kbd><span class="option">-a</span></kbd></dt>
<dd><p>删除所有别名定义</p>
</dd>
</dl>
</dd>
</dl>
</section>
<section id="set">
<h3>set<a class="headerlink" href="#set" title="Permalink to this heading"></a></h3>
<p>设置一个可设置参数、或显示参数的当前设置。</p>
<p>用法：</p>
<blockquote>
<div><p>set [-h] [-a] [-l] [settable [settable …]]</p>
</div></blockquote>
<ul class="simple">
<li><p>调用时不加参数可罗列可设置参数及其取值。</p></li>
</ul>
<dl>
<dt>选项：</dt><dd><dl class="option-list">
<dt><kbd><span class="option">-h</span></kbd></dt>
<dd><p>显示此帮助信息而后退出</p>
</dd>
<dt><kbd><span class="option">-a</span></kbd></dt>
<dd><p>也显示只读设置</p>
</dd>
<dt><kbd><span class="option">-l</span></kbd></dt>
<dd><p>参数的描述函数</p>
</dd>
</dl>
</dd>
</dl>
</section>
<section id="edit">
<h3>edit<a class="headerlink" href="#edit" title="Permalink to this heading"></a></h3>
<p>在一个文本编辑器内编辑文件。</p>
<p>用法：</p>
<blockquote>
<div><p>edit [file_path]</p>
</div></blockquote>
<ul class="simple">
<li><p>file_path - 要用编辑器打开的文件路径</p></li>
</ul>
</section>
<section id="run-script">
<h3>run_script<a class="headerlink" href="#run-script" title="Permalink to this heading"></a></h3>
<p>运行脚本文件里的命令，文本编码格式为 ASCII 或 UTF-8 。
脚本里的各个命令应该用换行符分隔。</p>
<p>用法：</p>
<blockquote>
<div><p>run_script &lt;file_path&gt;</p>
</div></blockquote>
<ul class="simple">
<li><p>file_path - 脚本文件的路径</p></li>
</ul>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>cmd2 版本为 0.9.13 或更低时，此命令名为 <code class="docutils literal notranslate"><span class="pre">load</span></code> 。</p>
</div>
</section>
<section id="shell">
<h3>shell<a class="headerlink" href="#shell" title="Permalink to this heading"></a></h3>
<p>像在操作系统提示符下一样，执行一个命令。</p>
<p>用法：</p>
<blockquote>
<div><p>shell &lt;command&gt; [arguments]</p>
</div></blockquote>
</section>
<section id="locate">
<h3>locate<a class="headerlink" href="#locate" title="Permalink to this heading"></a></h3>
<p>在文件系统里查找一个条目。</p>
<p>用法：</p>
<blockquote>
<div><p>locate [options] &lt;name&gt;</p>
</div></blockquote>
<dl>
<dt>选项：</dt><dd><dl class="option-list">
<dt><kbd><span class="option">-c</span></kbd></dt>
<dd><p>统计找到的条数</p>
</dd>
<dt><kbd><span class="option">-i</span></kbd></dt>
<dd><p>忽略大小写</p>
</dd>
</dl>
</dd>
</dl>
</section>
<section id="stat">
<h3>stat<a class="headerlink" href="#stat" title="Permalink to this heading"></a></h3>
<p>显示文件状态。</p>
<p>用法：</p>
<blockquote>
<div><p>stat [-h] &lt;file_name&gt; [file_name …]</p>
</div></blockquote>
<dl>
<dt>选项：</dt><dd><dl class="option-list">
<dt><kbd><span class="option">-h</span></kbd></dt>
<dd><p>显示帮助信息</p>
</dd>
</dl>
</dd>
</dl>
</section>
<section id="snap">
<h3>snap<a class="headerlink" href="#snap" title="Permalink to this heading"></a></h3>
<p>创建或删除快照。</p>
<p>用法：</p>
<blockquote>
<div><p>snap {create|delete} &lt;snap_name&gt; &lt;dir_name&gt;</p>
</div></blockquote>
<ul class="simple">
<li><p>snap_name - 要创建或删除的快照名。</p></li>
<li><p>dir_name - 目录，将在它下面创建或删除快照</p></li>
</ul>
</section>
<section id="setxattr">
<h3>setxattr<a class="headerlink" href="#setxattr" title="Permalink to this heading"></a></h3>
<p>设置一个文件的扩展属性。</p>
<p>用法：</p>
<blockquote>
<div><p>setxattr [-h] &lt;path&gt; &lt;name&gt; &lt;value&gt;</p>
</div></blockquote>
<ul class="simple">
<li><p>path - 文件的路径</p></li>
<li><p>name - 查看或设置的扩展属性名字。</p></li>
<li><p>value - 要设置的扩展属性值。</p></li>
</ul>
<dl>
<dt>选项：</dt><dd><dl class="option-list">
<dt><kbd><span class="option">-h</span>, <span class="option">--help</span></kbd></dt>
<dd><p>显示帮助信息</p>
</dd>
</dl>
</dd>
</dl>
</section>
<section id="getxattr">
<h3>getxattr<a class="headerlink" href="#getxattr" title="Permalink to this heading"></a></h3>
<p>获取指定路径和名字的扩展属性的值。</p>
<p>用法：</p>
<blockquote>
<div><p>getxattr [-h] &lt;path&gt; &lt;name&gt;</p>
</div></blockquote>
<ul class="simple">
<li><p>path - 文件的路径</p></li>
<li><p>name - 要获取或设置的扩展属性名</p></li>
</ul>
<dl>
<dt>选项：</dt><dd><dl class="option-list">
<dt><kbd><span class="option">-h</span>, <span class="option">--help</span></kbd></dt>
<dd><p>显示帮助信息</p>
</dd>
</dl>
</dd>
</dl>
</section>
<section id="listxattr">
<h3>listxattr<a class="headerlink" href="#listxattr" title="Permalink to this heading"></a></h3>
<p>罗列指定路径的扩展属性名。</p>
<p>用法：</p>
<blockquote>
<div><p>listxattr [-h] &lt;path&gt;</p>
</div></blockquote>
<ul class="simple">
<li><p>path - 文件的路径</p></li>
</ul>
<dl>
<dt>选项：</dt><dd><dl class="option-list">
<dt><kbd><span class="option">-h</span>, <span class="option">--help</span></kbd></dt>
<dd><p>显示帮助信息</p>
</dd>
</dl>
</dd>
</dl>
</section>
<section id="df">
<h3>df<a class="headerlink" href="#df" title="Permalink to this heading"></a></h3>
<p>显示可用磁盘空间的数量。</p>
<p>用法：</p>
<blockquote>
<div><p>df [-h] [file [file …]]</p>
</div></blockquote>
<ul class="simple">
<li><p>file - 文件名</p></li>
</ul>
<dl>
<dt>选项：</dt><dd><dl class="option-list">
<dt><kbd><span class="option">-h</span>, <span class="option">--help</span></kbd></dt>
<dd><p>显示帮助信息</p>
</dd>
</dl>
</dd>
</dl>
</section>
<section id="du">
<h3>du<a class="headerlink" href="#du" title="Permalink to this heading"></a></h3>
<p>显示一个目录占用的磁盘空间。</p>
<p>用法：</p>
<blockquote>
<div><p>du [-h] [-r] [paths [paths …]]</p>
</div></blockquote>
<ul class="simple">
<li><p>paths - 目录名</p></li>
</ul>
<dl>
<dt>选项：</dt><dd><dl class="option-list">
<dt><kbd><span class="option">-h</span>, <span class="option">--help</span></kbd></dt>
<dd><p>显示帮助信息</p>
</dd>
<dt><kbd><span class="option">-r</span></kbd></dt>
<dd><p>所有目录的递归磁盘占用量。</p>
</dd>
</dl>
</dd>
</dl>
</section>
<section id="quota">
<h3>quota<a class="headerlink" href="#quota" title="Permalink to this heading"></a></h3>
<p>一个目录的配额管理。</p>
<p>用法：</p>
<blockquote>
<div><p>quota [-h] [--max_bytes [MAX_BYTES]] [--max_files [MAX_FILES]] {get,set} path</p>
</div></blockquote>
<ul class="simple">
<li><p>{get,set} - 配额操作类型。</p></li>
<li><p>path - 目录名.</p></li>
</ul>
<dl>
<dt>选项：</dt><dd><dl class="option-list">
<dt><kbd><span class="option">-h</span>, <span class="option">--help</span></kbd></dt>
<dd><p>显示帮助信息</p>
</dd>
<dt><kbd><span class="option">--max_bytes <var>MAX_BYTES</var></span></kbd></dt>
<dd><p>设置此目录下数据的最大累计尺寸</p>
</dd>
<dt><kbd><span class="option">--max_files <var>MAX_FILES</var></span></kbd></dt>
<dd><p>设置此目录树下的文件总数</p>
</dd>
</dl>
</dd>
</dl>
</section>
</section>
<section id="id5">
<h2>CephFS Shell 配置文件<a class="headerlink" href="#id5" title="Permalink to this heading"></a></h2>
<p>默认情况下， CephFS Shell 会在 <code class="docutils literal notranslate"><span class="pre">CEPHFS_SHELL_CONF</span></code> 环境变量里的路径内寻找
<code class="docutils literal notranslate"><span class="pre">cephfs-shell.conf</span></code> ，而后才是用户的家目录（ <code class="docutils literal notranslate"><span class="pre">~/.cephfs-shell.conf</span></code> ）。</p>
<p>现在， CephFS Shell 从它依赖的 <code class="docutils literal notranslate"><span class="pre">cmd2</span></code> 那里继承了所有选项，
因此，这些选项可能会因你安装的 <code class="docutils literal notranslate"><span class="pre">cmd2</span></code> 版本而有很大差异。
关于这些选项的描述可以参考 <code class="docutils literal notranslate"><span class="pre">cmd2</span></code> 文档。</p>
<p>下面是个 <code class="docutils literal notranslate"><span class="pre">cephfs-shell.conf</span></code> 样板：</p>
<div class="highlight-ini notranslate"><div class="highlight"><pre><span></span><span class="k">[cephfs-shell]</span>
<span class="na">prompt</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">CephFS:~/&gt;&gt;&gt;</span>
<span class="na">continuation_prompt</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&gt;</span>

<span class="na">quiet</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">False</span>
<span class="na">timing</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">False</span>
<span class="na">colors</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">True</span>
<span class="na">debug</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">False</span>

<span class="na">abbrev</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">False</span>
<span class="na">autorun_on_edit</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">False</span>
<span class="na">echo</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">False</span>
<span class="na">editor</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">vim</span>
<span class="na">feedback_to_output</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">False</span>
<span class="na">locals_in_py</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">True</span>
</pre></div>
</div>
</section>
<section id="id6">
<h2>退出代码<a class="headerlink" href="#id6" title="Permalink to this heading"></a></h2>
<p>cephfs shell 能够返回下列退出代码：</p>
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>错误类型</p></th>
<th class="head"><p>退出代码</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>Miscellaneous</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p>Keyboard Interrupt</p></td>
<td><p>2</p></td>
</tr>
<tr class="row-even"><td><p>Operation not permitted</p></td>
<td><p>3</p></td>
</tr>
<tr class="row-odd"><td><p>Permission denied</p></td>
<td><p>4</p></td>
</tr>
<tr class="row-even"><td><p>No such file or directory</p></td>
<td><p>5</p></td>
</tr>
<tr class="row-odd"><td><p>I/O error</p></td>
<td><p>6</p></td>
</tr>
<tr class="row-even"><td><p>No space left on device</p></td>
<td><p>7</p></td>
</tr>
<tr class="row-odd"><td><p>File exists</p></td>
<td><p>8</p></td>
</tr>
<tr class="row-even"><td><p>No data available</p></td>
<td><p>9</p></td>
</tr>
<tr class="row-odd"><td><p>Invalid argument</p></td>
<td><p>10</p></td>
</tr>
<tr class="row-even"><td><p>Operation not supported on transport endpoint</p></td>
<td><p>11</p></td>
</tr>
<tr class="row-odd"><td><p>Range error</p></td>
<td><p>12</p></td>
</tr>
<tr class="row-even"><td><p>Operation would block</p></td>
<td><p>13</p></td>
</tr>
<tr class="row-odd"><td><p>Directory not empty</p></td>
<td><p>14</p></td>
</tr>
<tr class="row-even"><td><p>Not a directory</p></td>
<td><p>15</p></td>
</tr>
<tr class="row-odd"><td><p>Disk quota exceeded</p></td>
<td><p>16</p></td>
</tr>
<tr class="row-even"><td><p>Broken pipe</p></td>
<td><p>17</p></td>
</tr>
<tr class="row-odd"><td><p>Cannot send after transport endpoint shutdown</p></td>
<td><p>18</p></td>
</tr>
<tr class="row-even"><td><p>Connection aborted</p></td>
<td><p>19</p></td>
</tr>
<tr class="row-odd"><td><p>Connection refused</p></td>
<td><p>20</p></td>
</tr>
<tr class="row-even"><td><p>Connection reset</p></td>
<td><p>21</p></td>
</tr>
<tr class="row-odd"><td><p>Interrupted function call</p></td>
<td><p>22</p></td>
</tr>
</tbody>
</table>
</section>
<section id="id7">
<h2>相关文件<a class="headerlink" href="#id7" title="Permalink to this heading"></a></h2>
<p><code class="docutils literal notranslate"><span class="pre">~/.cephfs-shell.conf</span></code></p>
</section>
</section>



<div id="support-the-ceph-foundation" class="admonition note">
  <p class="first admonition-title">Brought to you by the Ceph Foundation</p>
  <p class="last">The Ceph Documentation is a community resource funded and hosted by the non-profit <a href="https://ceph.io/en/foundation/">Ceph Foundation</a>. If you would like to support this and our other efforts, please consider <a href="https://ceph.io/en/foundation/join/">joining now</a>.</p>
</div>


           </div>
           
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="../../../cephfs/ceph-dokan/" class="btn btn-neutral float-left" title="在 Windows 上挂载 CephFS" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="../../../cephfs/kernel-features/" class="btn btn-neutral float-right" title="内核驱动支持的功能" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2016, Ceph authors and contributors. Licensed under Creative Commons Attribution Share Alike 3.0 (CC-BY-SA-3.0).</p>
  </div>

   

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>